<template>
    <div>
      <city-header></city-header>
      <city-search :cities="cities"></city-search>
      <city-list :hotCities="hotCities" :cities="cities" :letter = "letter"></city-list>
      <city-alphabet :cities="cities" @change="changeAlpabet"></city-alphabet>
    </div>
</template>

<script>
import axios from 'axios'
import CityHeader from './components/header.vue'
import CitySearch from './components/search.vue'
import CityList from './components/list.vue'
import CityAlphabet from './components/alphabet.vue'
export default {
  props: {
  },
  data () {
    return {
      hotCities: [],
      cities: {},
      letter: ''
    }
  },
  methods: {
    getCity: function (res) {
      this.getCitySucc(res)
    },
    getCitySucc: function (res) {
      res = res.data
      if (res.ret && res.data) {
        this.hotCities = res.data.hotCities
        this.cities = res.data.cities
      }
    },
    changeAlpabet (letter) {
      this.letter = letter
    }
  },
  components: {CityHeader, CitySearch, CityList, CityAlphabet},
  computed: {},
  mounted () {
    axios.get('/api/city.json').then(this.getCity)
  }
}
</script>

<style lang="stylus" scoped>

</style>
